using System;
using Provausio.Common.Objects;
using TrainingManagement.api.Models.Data.CRUD;
using TrainingManagement.api.Models.Data.CRUD.SkillSet;

namespace TrainingManagement.api.Models.BusinessLogic.SkillSet
{
    public class SkillSetCreateOperation : BusinessOperation<BusinessObjects.SkillSet, BusinessObjects.SkillSet>
    {
        readonly SkillSetInsertDataSource _skillSetInsert = new SkillSetInsertDataSource();

        public override BusinessObjects.SkillSet Run(BusinessObjects.SkillSet input)
        {
            if (_skillSetInsert.Execute(input)) return input;
            
            throw new Exception("SkillSet was not saved!");
        }
    }
}